#ifndef WORKER_H_
#define WORKER_H_


//project specific headers
#include <PFileInfo.h>
#include "Validator/Validator.h"
#include "Validator/MetaFile.h"
#include "Zipper/Zipper.h"

class Worker
{
	public:
		Worker(PFileInfo theFile,Scheme theScheme)
		{
			(*myZipFile) = theFile;
			myAllOK = false;
			(*myScheme) = theScheme;
		}

		bool IsOK()
		{
			return myAllOK;
		}

		void operator() () //const
		{
			Zipper aZipper((*myZipFile));
			Scheme aZipScheme = aZipper.GetScheme();

			if(aZipScheme == (*myScheme))
			{
				std::vector<MetaFile> aFiles = (*myScheme).GetFiles();

				for(int i=0; i < aFiles.size(); i++)
				{		
					if(aFiles[i].DoExtract())
					{
						PFileInfo *aExtracted = NULL;
						if(aZipper.Extract(aFiles[i].GetName(),&aExtracted))
						{
							myExtractedFile.push_back(aExtracted);
						}
					}
				}
				myAllOK = true;
			}
			else
			{
				myAllOK = false;
			}

		}

		std::vector<PFileInfo*> GetExtractedFiles()
		{
			return myExtractedFile;
		}

	private:
		bool myAllOK;
		PFileInfo *myZipFile;
		std::vector<PFileInfo*> myExtractedFile;
		Scheme *myScheme;
		

};


#endif